Skip to content

Conversation

@buzkall
Copy link
Contributor

@buzkall buzkall commented Feb 2, 2024

In order to specify a different key than the model's one to be the parent key, you can use the ->withKey('name') method.

For example: you have id, code and parent_code in your model.
Your model uses id as key, but the parent-child relation is established between code and parent_code
In order to make SelectTree work with this model, you need to call the function ->withKey('code')

In order to specify a different key than the model's one to be the parent key, you can use the ->withKey('name') method
@CodeWithDennis
Copy link
Owner

I think replacing the $result->getKey() with a custom key is not a great move, since it could be different for everyone. The default should always be $result->getKey() unless it's overwritten.

@buzkall
Copy link
Contributor Author

buzkall commented Feb 2, 2024

You're right, I've changed it to call the model's getKey() function if no custom key is set

@CodeWithDennis CodeWithDennis merged commit 95d499f into CodeWithDennis:3.x Feb 2, 2024
@CodeWithDennis
Copy link
Owner

Reverted

@buzkall buzkall mentioned this pull request Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants